package com.learner.search.controller;

import com.learner.common.http.QueryResult;
import com.learner.pojo.course.CoursePub;
import com.learner.pojo.search.EsCourseKeys;
import com.learner.search.service.EsCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 搜索的控制器
 * @Author: ice2020x
 * @Date: 2021/8/22
 */
@RestController
@RequestMapping("/api/search/course")
public class EsCourseController {

    @Autowired
    EsCourseService esCourseService;

    /**
     * 通过关键字查询
     *
     * @param page         page
     * @param size         size
     * @param esCourseKeys es查询条件
     * @return 文件
     */
    @PostMapping(value = "/list/get/{page}/{size}")
    public QueryResult<CoursePub> listByKey(@PathVariable("page") int page, @PathVariable("size") int size, @RequestBody EsCourseKeys esCourseKeys) {
        System.out.println(page + size + esCourseKeys.toString());
        return esCourseService.listByKeys(page, size, esCourseKeys);
    }
}
